package com.cn.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 * 
 */
public class FormSubmitResult extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public FormSubmitResult() {
		put("code", 0);
	}
	public FormSubmitResult(String code,String msg,Object data){
		put("code", code);
		put("msg", msg);
		put("data", data);
	}
	
	public static FormSubmitResult error() {
		return FAILED(500, "未知异常，请联系管理员");
	}
	
	public static FormSubmitResult error(String msg) {
		return FAILED(500, msg);
	}
	
	public static FormSubmitResult FAILED(int code, String msg) {
		FormSubmitResult formSubmitResult = new FormSubmitResult();
		formSubmitResult.put("code", code);
		formSubmitResult.put("msg", msg);
		return formSubmitResult;
	}

	public static FormSubmitResult SUCCESS(String msg) {
		FormSubmitResult formSubmitResult = new FormSubmitResult();
		formSubmitResult.put("msg", msg);
		return formSubmitResult;
	}
	
	public static FormSubmitResult SUCCESS(Map<String, Object> map) {
		FormSubmitResult formSubmitResult = new FormSubmitResult();
		formSubmitResult.putAll(map);
		return formSubmitResult;
	}
	
	public static FormSubmitResult SUCCESS() {
		return new FormSubmitResult();
	}

	public FormSubmitResult put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
